[.NET] How to load multiple mscorlib.dll and call their inner functions seperately?
Posted
by Sean
on Stack Overflow
See other posts from Stack Overflow
or by Sean
Published on 2010-05-28T03:42:07Z
Indexed on
2010/05/28
3:51 UTC
Read the original article
Hit count: 476
Dears,
This is for research purpose. I have .Net framework 2.0 installed, and I want to load mscorlib.dll 1.1 dynamiclly to execute its specific inner function.
When I wrote this code in C#:
static void Main(string[] args)
{
Assembly assem = Assembly.LoadFrom("C:\\mscorlib_my_private_1.1.dll");
System.Type type = assem.GetType("System.Console");
Type[] typeArray =new Type[1];
typeArray.SetValue(typeof(string),0);
System.Reflection.MethodInfo info = type.GetMethod("WriteLine", typeArray);
object[] param = new object[1];
param[0] = assem.FullName;
type.InvokeMember("WriteLine",
System.Reflection.BindingFlags.InvokeMethod, System.Type.DefaultBinder,
"", param);
}
The output is "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Not the expected 1.1 version.
After Googling a lot, I know that mscorlib.dll is very special, but is it impossible?
Cheers~ Sean
© Stack Overflow or respective owner